//
//  FMSViewController.m
//  FMS
//
//  Created by Steven on 10/11/13.
//  Copyright (c) 2013 QGSVN. All rights reserved.
//

#import "FMSViewController.h"
#import "UIScreen+iPhone5.h"

@interface FMSViewController ()

@end

@implementation FMSViewController
@synthesize navBar = _navBar;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        language = [ApplicationDelegate.arrayLanguage objectAtIndex:0];
    }
    return self;
    
}
- (void)viewDidLoad
{

    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark util methods

- (void)addTopBar
{
    NSString* nibName = @"NavBarView";
    NSArray * nib = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
    _navBar = [nib objectAtIndex:0];
    [self.view addSubview:_navBar];
    [self.view bringSubviewToFront:_navBar];
    
//    LOGAPP(@"ADD TOP BAR");
}
- (void)addLoadingView{
    activityView = [[UIActivityIndicatorView alloc] init];
    if(!isIPAD())
    {
        if([[UIScreen mainScreen] isiPhone5])
        {
            activityView.frame = CGRectMake(320/2 - 30.0/2, (568-20)/2 - 30/2, 30, 30);
        }else
        {
            activityView.frame = CGRectMake(320/2 - 30.0/2, (480-20)/2 - 30.0/2, 30.0, 30.0);
        }
    }else
    {
        activityView.frame = CGRectMake(1024/2 - 30.0/2, 768/2 - 30.0/2, 30.0, 30.0);
    }
    activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
    [self.view addSubview:activityView];
    activityView.hidden = YES;
}
- (void)showHiddenActivityProgess:(BOOL)isYES
{
    activityView.hidden = !isYES;
    if (isYES) {
        [activityView startAnimating];
    }
    else
        [activityView stopAnimating];
    
}
- (void)showErrorMessage:(NSString *)message{
    UIAlertView *dialog = [[UIAlertView alloc] initWithTitle:[language objectForKey:@"general.warning"] message:message delegate:nil cancelButtonTitle:[language objectForKey:@"general.ok"] otherButtonTitles:nil];
    [dialog show];
}

- (void)didmissPopoverController{
    if (popoverController) {
        [popoverController dismissPopoverAnimated:YES];
        popoverController = nil;
    }
}
@end
